package com.typhoon.spring_boot_demo1.service.impl;

import com.typhoon.spring_boot_demo1.bean.Order;
import com.typhoon.spring_boot_demo1.bean.User;
import com.typhoon.spring_boot_demo1.dto.SearchResultDto;
import com.typhoon.spring_boot_demo1.request.Operator;
import com.typhoon.spring_boot_demo1.service.AbstractSearch;
import com.typhoon.spring_boot_demo1.service.OrderService;
import com.typhoon.spring_boot_demo1.service.UserService;
import com.typhoon.spring_boot_demo1.utils.ConvertUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 订单查询实现
 *
 */
@Service
public class OrderSearchImpl extends AbstractSearch {

    @Autowired
    private OrderService orderService;

    @Override
    public List<SearchResultDto> bizSearch(String key, Operator operator) {
        if(!StringUtils.isNumeric(key)) {
            return null;
        }
        List<SearchResultDto> list = new ArrayList<>();
        Order order = this.orderService.queryByOrderId(Long.valueOf(key));
        if(null == order) {
            return list;
        }
        list.add(ConvertUtils.convertSearchResultDto(order));
        return list;
    }
}
